package org.datedemo;

//1.导入Date类

import org.webrx.D;

import java.util.Date;

public class Date1 {
    public static void main(String[] args) {
        //java.util.Date 类位置
        Date d = new Date(); //2.实例化类 类Date 对象(实例)dd

        //日期 计算机发展史千年虫？ bug 911 log4j2  1985 85 1997 97
        //97-10-03 2000 9999-03-15

        //时间戳 long类型的数字用来表达日期Date
        System.out.println(d.getTime()); //1686109457087

        int h = d.getHours();
        System.out.println(h);
        System.out.println(d.getDate());
        System.out.println(d.getDay());//3
        System.out.println(d.getMonth() + 1);

        int k = d.getDay();
        if (k == 0) System.out.println("星期日");
        if (k == 1) System.out.println("星期一");
        if (k == 2) System.out.println("星期二");
        if (k == 3) System.out.println("星期三");
        if (k == 4) System.out.println("星期四");
        if (k == 5) System.out.println("星期五");
        if (k == 6) System.out.println("星期六");


        System.out.println(d.getYear() + 1900);


        //输出
        System.out.println(d);//3.直接输出实例

        //格式化输出
        //System.out.printf("%tF %tT%n",d,d);
        System.out.printf("%tF %<tT%n", d);


        Date d2 = new Date(1L);
        System.out.printf("%tF %<tT%n", d2); //1970-01-01 08:00:00 001

    }
}
